package com.zzz.offer.numpower;

public class DoublePoser {
    public double Power(double base, int exponent) {
        int r = 1;
        boolean ifNegative = false;
        if (exponent < 0) {
            exponent = -exponent;
            ifNegative = true;
        }
        while (exponent > 0) {
            r *= base;
            exponent--;
        }
        if (!ifNegative) {
            r = 1 / r;
        }
        return r;
    }
}
